package com.charlotte.study.gupao.adapter.login.v1;

import org.apache.commons.lang3.StringUtils;

/**
 * @author junjie.ding
 * @date 2020/3/11
 */
public class PassportForThirdAdapter extends PassportService implements IPassportForThird {

    @Override
    public BaseResponse loginForQQ(String mid) {
        return loginForRegister(mid, null);
    }

    @Override
    public BaseResponse loginForWechat(String mid) {
        return loginForRegister(mid, null);
    }

    @Override
    public BaseResponse loginForAli(String mid) {
        return loginForRegister(mid, null);
    }

    @Override
    public BaseResponse loginForTelphone(String phone, String code) {
        return loginForRegister(phone, null);
    }


    private BaseResponse loginForRegister(String username, String password){
        if(StringUtils.isBlank(password)){
            password = "THIRD_EMPTY";
        }
        super.register(username, password);
        return super.login(username, password);
    }
}
